package com.sugar.psych.assessment.module.business.dal.mysql.studentauth;


import com.sugar.psych.assessment.framework.common.pojo.PageResult;
import com.sugar.psych.assessment.framework.mybatis.core.mapper.BaseMapperX;
import com.sugar.psych.assessment.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.sugar.psych.assessment.module.business.dal.dataobject.school.SchoolDO;
import com.sugar.psych.assessment.module.business.dal.dataobject.studentauth.StudentAuthDO;
import org.apache.ibatis.annotations.Mapper;
import com.sugar.psych.assessment.module.business.controller.admin.studentauth.vo.*;

/**
 * 学生认证信息 Mapper
 *
 * @author Ysugar
 */
@Mapper
public interface StudentAuthMapper extends BaseMapperX<StudentAuthDO> {

    default PageResult<StudentAuthRespVO> selectPage(StudentAuthPageReqVO reqVO) {
        return selectJoinPage(reqVO, StudentAuthRespVO.class, new MPJLambdaWrapperX<StudentAuthDO>()
                .selectAll(StudentAuthDO.class)
                .selectAs(SchoolDO::getName, StudentAuthRespVO::getSchoolName)
                .leftJoin(SchoolDO.class, SchoolDO::getId, StudentAuthDO::getSchoolId)
                .likeIfPresent(SchoolDO::getName, reqVO.getSchoolName())
                .eqIfPresent(StudentAuthDO::getMobile, reqVO.getMobile())
                .likeIfPresent(StudentAuthDO::getAuthName, reqVO.getAuthName())
                .eqIfPresent(StudentAuthDO::getAuthId, reqVO.getAuthId())
                .eqIfPresent(StudentAuthDO::getIsAuth, reqVO.getIsAuth())
                .betweenIfPresent(StudentAuthDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StudentAuthDO::getId));
    }

}